//
//  TrackDayViewController.m
//  TheRoadAD
//
//  Created by 宁宁 on 16/8/18.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "TrackDayViewController.h"

#import "TunerTableViewCell.h"//cell

#import "OthersHomePageViewController.h"//他人主页Controller
#import "TrackDayDetailViewController.h"//活动详情Controller

#import "ActivitySearchViewController.h"//搜索Controller

@interface TrackDayViewController () <UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation TrackDayViewController

 static NSString *const TunerTableViewCellID = @"TunerTableViewCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNav:_temp];
    
    [self registerTableView];
}

- (void)setNav:(int)temp{
    switch (temp) {
        case 0:
            self.title = @"赛道日";
            break;
        case 1:
            self.title = @"自驾游";
            break;
        case 2:
            self.title = @"静态展示";
            break;
        case 3:
            self.title = @"室内聚会";
            break;
        case 4:
            self.title = @"兜一兜";
            break;
        case 5:
            self.title = @"越野";
            break;
        case 6:
            self.title = @"婚车租赁";
            break;
        default:
            break;
    }
    
    UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_find"] style:UIBarButtonItemStylePlain target:self action:@selector(searchActivity)];
    self.navigationItem.rightBarButtonItem = search;
}



- (void)registerTableView{
    [self.tableView registerNib:[UINib nibWithNibName:@"TunerTableViewCell" bundle:nil] forCellReuseIdentifier:@"TunerTableViewCell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TunerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TunerTableViewCell"];
    cell.name.text = @"用户名";
    cell.time.text = @"2016-05-20 16:55";
    cell.picNum.text = @"9图";
    cell.content.text = @"21号下午黄龙约起!";
    
//    if (@"自己") {
//        [cell.firstBtn setTitle:@"筛选" forState:UIControlStateNormal];
//        [cell.firstBtn setImage:[UIImage imageNamed:@"icon_baoming"] forState:UIControlStateNormal];
//    }else{
        [cell.firstBtn setTitle:@"报名" forState:UIControlStateNormal];
        [cell.firstBtn setImage:[UIImage imageNamed:@"icon_baoming"] forState:UIControlStateNormal];
//    }
    
    cell.cellClick = ^(int temp){
        switch (temp) {
            case 0:
            {
//                if (@"自己") {
//                    NSLog(@"筛选");
//                }else {
                    NSLog(@"报名");
//                }
            }
                break;
            case 1:
            {
                NSLog(@"评论");
            }
                break;
            case 2:
            {
                NSLog(@"分享");
            }
                break;
            case 3:
            {
                OthersHomePageViewController *others = [[OthersHomePageViewController alloc] init];
                others.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:others animated:YES];
            }
            default:
                break;
        }
    };
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //有内容140 没内容100
    return 140 + Screen_Width / 25 * 12;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    TrackDayDetailViewController *detail = [[TrackDayDetailViewController alloc] init];
    detail.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:detail animated:YES];
}


- (void)searchActivity{
    ActivitySearchViewController *search = [[ActivitySearchViewController alloc] init];
    search.index = _temp;
    search.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:search animated:YES];
}


- (UITableView *)tableView{
    if (!_tableView) {
        _tableView= [[UITableView alloc]initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height)style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.showsVerticalScrollIndicator = NO;//去掉滑动竖条
        [self.view addSubview:_tableView];
    }
    return _tableView;
}

@end
